#include <iostream>
#include <vector>
using namespace std;
class Solution {
public:
    vector<int> twoSum(vector<int>& numbers, int target) {
      int pos1 = 0;
      int pos2 = numbers.size() - 1;
      while(pos1 < pos2){
	if(numbers[pos1] + numbers[pos2] == target){
	  return {pos1+1,pos2+1};
	}else if(numbers[pos1] + numbers[pos2] > target){
	  --pos2;
	}else{
	  ++pos1;
	}
      }
      return {};
    }
};

int main()
{
	vector<int> a = {2,7,11,15};
	Solution s;
	auto q = s.twoSum(a, 9);
	for(auto p = q.begin(); p != q.end();++p){
		cout<<*p<<" ";
	}
	cout<<endl;
}
